<template>
  <c-select
    v-bind="$attrs"
    v-on="$listeners"
    filterable
    :value="value"
    :options="orgList"
    @change="hangleChange"
    :props="props"
  ></c-select>
</template>

<script>
export default {
  components: {},
  props: {
    value: {
      type: String,
      default: '',
    },
  },
  model: {
    prop: 'value',
    event: 'change',
  },
  data() {
    return {
      props: {
        value: 'credit_agency_info_id',
        label: 'agency_name',
      },
      params: {
        'agency_type.eq': 6,
        'org_region_lever.lte': 2,
      },
      order: {
        create_time: 'desc',
      },
      tableName: 'credit_agency_info',
    }
  },
  computed: {
    orgList() {
      return this.$store.getters.account
    },
  },
  watch: {},
  created() {
    this.getData()
  },
  mounted() {},
  methods: {
    getData() {
      this.$store.dispatch('getAccountData', true)
    },
    hangleChange(val) {
      const select = this.orgList.find(item => item.credit_agency_info_id === val) || {}
      this.$emit('select', val, select.agency_name)
    },
  },
}
</script>

<style lang="scss" scoped></style>
